package com.my.zl.console.controller.online;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.my.zl.common.dto.ReqDTO;
import com.my.zl.common.dto.ResDTO;
import com.my.zl.common.dto.advancedQuery.PageQueryDTO;
import com.my.zl.console.common.aop.LogAnnotation;
import com.my.zl.console.common.aop.NoLogAnnotation;
import com.my.zl.console.controller.base.BaseController;
import com.my.zl.console.dto.online.databaseInfo.ReqDatabaseInfoAddDTO;
import com.my.zl.console.dto.online.databaseInfo.ReqDatabaseInfoDelDTO;
import com.my.zl.console.dto.online.databaseInfo.ReqDatabaseInfoDetailDTO;
import com.my.zl.console.dto.online.databaseInfo.ReqDatabaseInfoEditDTO;
import com.my.zl.console.dto.online.databaseInfo.ReqDatabaseInfoQueryDTO;
import com.my.zl.console.dto.online.databaseInfo.ReqDatabaseInfoStateDTO;
import com.my.zl.console.dto.online.databaseInfo.ResDatabaseInfoAddDTO;
import com.my.zl.console.dto.online.databaseInfo.ResDatabaseInfoDelDTO;
import com.my.zl.console.dto.online.databaseInfo.ResDatabaseInfoDetailDTO;
import com.my.zl.console.dto.online.databaseInfo.ResDatabaseInfoEditDTO;
import com.my.zl.console.dto.online.databaseInfo.ResDatabaseInfoQueryDTO;
import com.my.zl.console.dto.online.databaseInfo.ResDatabaseInfoStateDTO;
import com.my.zl.console.service.online.IDatabaseInfoService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 数据库配置
 * @author ZL
 */
@Api(value="数据库配置",tags ="数据库配置")
@Controller
@RequestMapping("/api/online/databaseInfo")
public class DatabaseInfoController extends BaseController {

    @Autowired
    private IDatabaseInfoService databaseInfoService;
    
    /**
     * 查询
     */
    @NoLogAnnotation
    @ResponseBody
    @RequestMapping(value="/list", method = RequestMethod.GET)
    public ResDTO<ResDatabaseInfoQueryDTO> listDatabaseInfo(ReqDatabaseInfoQueryDTO reqInfo,PageQueryDTO page) throws Exception{
        ResDatabaseInfoQueryDTO data = databaseInfoService.queryDatabaseInfoList(reqInfo,page);
        return successDATA(data);
    }
    
   /**
     * 详情
     */
    @NoLogAnnotation
    @ResponseBody
    @RequestMapping(value="/detail", method = RequestMethod.GET)
    public ResDTO<ResDatabaseInfoDetailDTO> detailDatabaseInfo(ReqDatabaseInfoDetailDTO reqInfo) throws Exception{
        ResDatabaseInfoDetailDTO data = databaseInfoService.queryDatabaseInfoDetail(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 新增
     */
    @NoLogAnnotation
    @ResponseBody
    @RequestMapping(value="/add", method = RequestMethod.POST)
    public ResDTO<ResDatabaseInfoAddDTO> addDatabaseInfo(@RequestBody ReqDTO<ReqDatabaseInfoAddDTO> reqInfo) throws Exception{
        ResDatabaseInfoAddDTO data = databaseInfoService.insertDatabaseInfoInfo(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 编辑
     */
    @NoLogAnnotation
    @ResponseBody
    @RequestMapping(value="/edit", method = RequestMethod.POST)
    public ResDTO<ResDatabaseInfoEditDTO> editDatabaseInfo(@RequestBody ReqDTO<ReqDatabaseInfoEditDTO> reqInfo) throws Exception{
        ResDatabaseInfoEditDTO data = databaseInfoService.updateDatabaseInfoInfo(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 删除
     */
    @NoLogAnnotation
    @ResponseBody
    @RequestMapping(value="/del", method = RequestMethod.POST)
    public ResDTO<ResDatabaseInfoDelDTO> delDatabaseInfo(@RequestBody ReqDTO<ReqDatabaseInfoDelDTO> reqInfo) throws Exception{
        ResDatabaseInfoDelDTO data = databaseInfoService.deleteDatabaseInfoInfo(reqInfo);
        return successDATA(data); 
    }
    
    /**
     * 状态更新
     */
    @NoLogAnnotation
    @ResponseBody
    @RequestMapping(value="/state", method = RequestMethod.POST)
    public ResDTO<ResDatabaseInfoStateDTO> stateDatabaseInfo(@RequestBody ReqDTO<ReqDatabaseInfoStateDTO> reqInfo) throws Exception{
        ResDatabaseInfoStateDTO data = databaseInfoService.updateDatabaseInfoState(reqInfo);
        return successDATA(data); 
    }
    
    
}